package com.fit.spring.boot.mapper.autoconfigure;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.Environment;

/**
 * 获取Environment对象的后置处理器
 * @author hcl
 *
 */
public class ObtainEnvironmentPostProcessor implements EnvironmentPostProcessor{

	private static Environment environment;
	
	/**
	 * 后置处理器
	 * 此方执行时只加载了application.properties配置文件中的配置项
	 */
	@Override
	public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
		ObtainEnvironmentPostProcessor.environment = environment;
	}
	
	/**
	 * 获取Environment
	 * @return
	 */
	protected static Environment getEnvironment(){
		return environment;
	}

}
